home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 317 / asmsrc / gdb.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-10-20  |  2.7 KB  |  110 lines

  1. /* gdb.c -as supports gdb- */
  2.  
  3. /* Copyright (C) 1987 Free Software Foundation, Inc.
  4.  
  5. This file is part of Gas, the GNU Assembler.
  6.  
  7. The GNU assembler is distributed in the hope that it will be
  8. useful, but WITHOUT ANY WARRANTY.  No author or distributor
  9. accepts responsibility to anyone for the consequences of using it
  10. or for whether it serves any particular purpose or works at all,
  11. unless he says so in writing.  Refer to the GNU Assembler General
  12. Public License for full details.
  13.  
  14. Everyone is granted permission to copy, modify and redistribute
  15. the GNU Assembler, but only under the conditions described in the
  16. GNU Assembler General Public License.  A copy of this license is
  17. supposed to have been given to you along with the GNU Assembler
  18. so you can know your rights and responsibilities.  It should be
  19. in a file named COPYING.  Among other things, the copyright
  20. notice and this notice must be preserved on all copies.  */
  21.  
  22. /* This code is independent of the underlying operating system. */
  23.  
  24. #include "as.h"
  25.  
  26. static long int        size;    /* 0 or size of GDB symbol file. */
  27. static char *        where;    /* Where we put symbol file in memory. */
  28.  
  29. #define SUSPECT        /* JF */
  30.  
  31. long int            /* 0 means don't call gdb_... routines */
  32. gdb_begin (filename)        /* because we failed to establish file */
  33.                 /* in memory. */
  34.      char * filename;        /* NULL: we have nothing to do. */
  35. {
  36.   long int        gdb_file_size();
  37.   char *        xmalloc();
  38.   void            gdb_file_begin();
  39.   void            gdb_file_read();
  40.   void            gdb_block_begin();
  41.   void            gdb_symbols_begin();
  42.  
  43.   gdb_file_begin();
  44.   size = 0;
  45.   if (filename && (size = gdb_file_size (filename)))
  46.     {
  47.       where = xmalloc( (long) size );
  48.       gdb_file_read (where, filename);    /* Read, then close file. */
  49.       gdb_block_begin();
  50.       gdb_symbols_begin();
  51.     }
  52.   return (size);
  53. }
  54.  
  55. void
  56. gdb_end()
  57. {
  58.   void gdb_file_end();
  59.  
  60.   gdb_file_end();
  61. }
  62.  
  63. void
  64. gdb_emit (filename)    /* Append GDB symbols to object file. */
  65. char *    filename;
  66. {
  67.   void gdb_block_emit();
  68.   void gdb_symbols_emit();
  69.   void gdb_lines_emit();
  70.   void output_file_append();
  71.  
  72.   gdb_block_emit ();
  73.   gdb_symbols_emit ();
  74.   gdb_lines_emit();
  75.   output_file_append (where, size, filename);
  76. }
  77.  
  78.  
  79.  
  80. /*
  81.     Notes:    We overwrite what was there.
  82.         We assume all overwrites are 4-char numbers.
  83. */
  84.  
  85. void
  86. gdb_alter (offset, value)    /* put value into GDB file + offset. */
  87.      long int    offset;
  88.      long int    value;
  89. {
  90.   void md_number_to_chars();
  91. #ifdef SUSPECT
  92.  
  93.   if (offset > size - sizeof(long int) || offset < 0)
  94.     {
  95.       as_warn( "gdb_alter: offset=%d. size=%ld.\n", offset, size );
  96.     }
  97.   else
  98.     {
  99.  
  100. #endif
  101.  
  102.       md_number_to_chars (where + offset, value, 4);
  103.  
  104. #ifdef SUSPECT
  105.     }
  106. #endif
  107. }
  108.  
  109. /* end: gdb.c */
  110.